﻿#ifndef READMEMSDATACODEC_H
#define READMEMSDATACODEC_H

#include <qobject.h>
#include "ObjAutoInject.h"
#include <qdatetime.h>
#include <qhash.h>
#include <qvector.h>

#include "MEMSData.h"

class TcpCodec;
class ReadMEMSDataCodec_Client :  public QObject,public ObjAutoInject
{
  Q_OBJECT

public:
  enum ReadType{
    ReadAll=0x00,
    ReadByDateTime=0x01
  };
private://property
  QHash<uchar,void(ReadMEMSDataCodec_Client::*)(QByteArray)> funMap;
private://dependency
  TcpCodec* tcpCodec=Q_NULLPTR;
public:
  explicit ReadMEMSDataCodec_Client(QObject *parent = nullptr);

signals:
  void signal_readAll(QVector<MEMSData> list);
  void signal_ReadByDateTime(QVector<MEMSData> list);
public:
  void code(uchar readType,QByteArray data=QByteArray());
  void decode(QByteArray data);
  void readAll();
  void readByTime(QDateTime begin,QDateTime end);
private:
  void decode_readAll(QByteArray data);
  void decode_ReadByDateTime(QByteArray data);
public://geter and seter
  TcpCodec* getTcpCodec();
  void setTcpCodec(TcpCodec* tcpCodec);
public:
  virtual void objectAutoInjection(QHash<QString,QObject*>* objMap);
};

#endif // READMEMSDATACODEC_H
